FROM python:3.13-slim

WORKDIR /app

# 安装网络诊断工具
# 删除所有现有的 sources.list.d 配置文件
RUN rm -f /etc/apt/sources.list.d/*.list && \
    rm -f /etc/apt/sources.list.d/*.sources && \
    # 设置适用于 Debian Trixie 的阿里云镜像源
    echo "deb http://mirrors.aliyun.com/debian trixie main non-free non-free-firmware" > /etc/apt/sources.list && \
    echo "deb http://mirrors.aliyun.com/debian trixie-updates main non-free non-free-firmware" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.aliyun.com/debian trixie-backports main non-free non-free-firmware" >> /etc/apt/sources.list && \
    echo "deb http://mirrors.aliyun.com/debian-security trixie-security main non-free non-free-firmware" >> /etc/apt/sources.list && \
    apt-get update && \
    apt-get install -y --no-install-recommends \
        build-essential && \
    rm -rf /var/lib/apt/lists/*

# 复制依赖文件
COPY requirements.txt .

# 升级pip并安装依赖
RUN pip install --upgrade pip && \
    pip install --no-cache-dir -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

# 复制项目代码
COPY . .


# 暴露端口
EXPOSE 8851

# 启动命令
CMD ["python", "first_main.py"]